package com.qh.pay.service;

import java.math.BigDecimal;

import com.qh.common.utils.R;
import com.qh.pay.api.Order;
import com.qh.pay.api.utils.DateUtil;
import com.qh.pay.domain.MerchCharge;
import com.qh.pay.domain.Merchant;

/**
 * @version 1.0.0
 * @ClassName PayQrService
 * @Description 扫码通道支付
 * @Date 2017年12月19日 上午10:27:03
 */
public interface PayQrService {

    /**
     * @param order
     * @param merchant
     * @return
     * @Description 支付通道扫码
     */
    R qrOrder(Order order, Merchant merchant);

    /**
     * @param order
     * @Description 释放占用金额
     */
    void releaseMonAmount(Order order);

    /**
     * @param merchNo
     * @param outChannel
     * @param accountNo
     * @param monAmount
     * @param businessNo
     * @param msg
     * @Description 扫码通道异步回调
     */
    void notifyQr(String merchNo, String outChannel, String accountNo, String monAmount, String businessNo, String msg);

    void notifyQr(String outChannel, String accountNo, String monAmount, String msg,String date);
    void notifyQr(Order order);
    void saveQrOrderLoseData(String outChannel, String accountNo, String monAmount,
                                    String businessNo,
                                    String msg, String date);
    /**
     * @param monAmount
     * @param merchNo
     * @param outChannel
     * @Description 获取充值金额
     */
    R getChargeMon(String monAmount, String merchNo, String outChannel);

    /**
     * @param merchNo
     * @param outChannel
     * @param monAmount
     * @param businessNo
     * @param msg
     * @Description 充值金额回调
     */
    void notifyChargeQr(String merchNo, String outChannel, String accountNo, String monAmount, String businessNo,
						String msg);

    /**
     * @param chargeMerchNo
     * @param outChannel
     * @param monAmount
     * @param businessNo
     * @Description 初始化商户充值记录
     */
    static MerchCharge initMerchCharge(String chargeMerchNo, String outChannel, String monAmount, String businessNo) {
        MerchCharge merchCharge = new MerchCharge();
        merchCharge.setMerchNo(chargeMerchNo);
        merchCharge.setOutChannel(outChannel);
        merchCharge.setAmount(new BigDecimal(monAmount));
        merchCharge.setBusinessNo(businessNo);
        merchCharge.setCrtDate(DateUtil.getCurrentTimeInt());
        return merchCharge;
    }

    /**
     * @param merchNo
     * @param orderNo
     * @Description 商户充值保存
     */
    void chargeDataMsg(String merchNo, String orderNo);

    /**
     * @param order
     * @return
     * @Description (TODO这里用一句话描述这个方法的作用)
     */
    boolean saveQrOrderData(Order order);

    /**
     * @param merchNo
     * @param outChannel
     * @param monAmount
     * @param businessNo
     * @return
     * @Description 人工充值
     */
    R superChargeQr(String merchNo, String outChannel, String monAmount, String businessNo);

    /**
     * @param merchant
     * @param order
     * @param businessNo
     * @return
     * @Description 手动同步订单
     */
    R syncOrder(Merchant merchant, Order order, String businessNo);

}
